/**
 * Created by Administrator on 2018/6/13.
 */
function passwordCtrlInit($scope, $route, CertusFormAjax, CertusJsonAjax, $location, $http) {
    $scope.alterPasswordHttp = function () {
        var originPass = $("input[name='originPass']").val();
        var firstPass = $("input[name='firstPass']").val();
        var secondPass = $("input[name='secondPass']").val();
        if (originPass == "" || originPass == null) {
            parent.layer.msg("原密码不能为空！");
            return;
        }
        if (firstPass == "" || firstPass == null) {
            parent.layer.msg("新密码不能为空！");
            return;
        }
        if (secondPass == "" || secondPass == null) {
            parent.layer.msg("确认密码不能为空！");
            return;
        }
        if ($scope.isSame) {
            CertusJsonAjax.ajax("passwordSubmit", {
                originPass: $.md5($scope.map.originPass),
                firstPass: $.md5($scope.map.firstPass)
            }, function (response) {
                if (response.data == "success") {
                    parent.window.location.href = "login.html";
                } else {
                    parent.layer.msg("原密码不正确，修改失败！");
                }
            })
        }
    };

    $scope.passChange = function (a) {
        if (!a) {
            $("#showError").show();
            $scope.isSame = false;
        } else {
            $("#showError").hide();
            $scope.isSame = true;
        }
    }
}